package example2;

import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.StopWatch;
import org.junit.Test;

import javax.sound.sampled.*;
import java.io.File;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class BTest {

    @Test
    public void t1() throws Exception {
        //${Dt}
        String sql1 = "12345${Dt}qwer >=${Dt} lkjhg=${Dt} poi";

        String format = DateFormatUtils.format(new Date(), "yyyy-MM-dd");

        String replace = StringUtils.replace(sql1, "${Dt}", format);

        org.apache.commons.lang3.StringUtils.isNoneEmpty();
        System.out.println(replace);

        ExcelReader reader = ExcelUtil.getReader(new File(""));
        List<String> strings = reader.readAll(String.class);

    }

    @Test
    public void t2() throws Exception {
        String format = String.format("D%04d", 122);
        System.out.println(format);

        System.out.println(Long.MAX_VALUE);
    }

    @Test
    public void t3() throws Exception {
        Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
        int length = mixerInfo.length;
        for (Mixer.Info info : mixerInfo) {
            if (info.getDescription().indexOf("Playback") == -1) {
                continue;
            }
            Mixer mixer = AudioSystem.getMixer(info);
//            AudioSystem.getSourceDataLine()
            try {
                mixer.open();
                Line.Info[] lines = mixer.getSourceLineInfo();
                int length1 = lines.length;
                for (Line.Info lineInfo : lines) {
                    DataLine line =(DataLine) AudioSystem.getLine(lineInfo);
                    String name = line.getClass().getName();
                    float level = line.getLevel();
                    System.out.println(level);
                }
            } catch (LineUnavailableException e) {
                e.printStackTrace();
            }
        }
    }


    @Test
    public void testApacheStopWatch() throws Exception {

        StopWatch watch = new StopWatch();
        watch.start();

        watch.stop();

        String format = String.format("%02d:%02d:%02d", watch.getTime(TimeUnit.HOURS), watch.getTime(TimeUnit.MINUTES), watch.getTime(TimeUnit.SECONDS));
        System.out.println(format);
    }


}
